<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LoginModel
 *
 * @author Administrator
 */
namespace app\model;
use think\Model;
class LoginModel extends Model {
    //put your code here
    
    public function loginAdmin($data){
        $user = $this->where(['admin_name' => $data['admin_name']])->find();
//          $user = $this->getByName($data['username']);
          if($user){
              if( $user['password']===md5($data['password']) ){
                  session('id',$user['id']);
                  session('admin_name',$user['admin_name']);

                  return 2;//登录成功
              }
              else{
                  return 3; //密码错误
              }

          }else{
              return 1;//未找到用户；
          }

    }
}
